﻿using System;
using CSUtils;
using TripleJump;
using U3dGame;
using U3dGameUI;
using U3dUtils;
using UI00;
using UI02;
using UnityEngine;

namespace G02.TripleJump.UI {
    public class UIManage_TripleJump {
        public static UIManage_TripleJump GetInstance {
            get {
                if (instance == null) {
                    instance = new UIManage_TripleJump();
                }
                return instance;
            }
        }
        static UIManage_TripleJump instance;

        UIManage_TripleJump() {
        }

        /// <summary>
        /// 主界面
        /// </summary>
        public UI_Main ui_Main {
            get {
                if (_ui_Main == null) {
                    _ui_Main = UIManage.Open<UI_Main>();
                }
                return _ui_Main;
            }
        }
        UI_Main _ui_Main;

        public UI_GameEndRanking uI_GameEndRanking {
            get {
                if (_uI_GameEndRanking == null) {
                    _uI_GameEndRanking = new UI_GameEndRanking();
                    _uI_GameEndRanking.Open(null);
                }
                return _uI_GameEndRanking;
            }
        }
        UI_GameEndRanking _uI_GameEndRanking;

        /// <summary>
        /// 游戏设置
        /// </summary>
        public UI_Setup uI_Setup {
            get {
                if (_uI_Setup == null) {
                    _uI_Setup = new UI_Setup();
                    _uI_Setup.Open(null);
                }
                return _uI_Setup;
            }
        }
        UI_Setup _uI_Setup;
        /// <summary>
        /// 游戏帮助
        /// </summary>
        //public UI_Help uI_Help = new UI_Help();

        public UI_NpcPreview uI_NpcPreview {
            get {
                if (_uI_NpcPreview == null) {
                    _uI_NpcPreview = new UI_NpcPreview();
                    _uI_NpcPreview.Open(null);
                }
                return _uI_NpcPreview;
            }
        }
        UI_NpcPreview _uI_NpcPreview;

        public void _Init() {
            UI_Ads.prefabPath = "Game/G02/U3d_TripleJump/Resources/G02/UI/UI_Ads/UI_Ads.prefab";
            //SystemTipsUI.prefabPath = "Game/G02/U3d_TripleJump/Resources/G02/UI/UI_SystemHints/UI_SystemHints.prefab";
            //UI_BloodStrip.prefabPath = "Game/G02/U3d_TripleJump/Resources/G02/UI/UI_BloodStrip/UI_BloodStrip.prefab";

            CMusicManage.Init();

            if (false) {
                UI_Setup.S_GameInit();
            }
//            CDelayMain.Delay(0.4f).SetPauseEnd("").onCallback = delegate {
//                UIBase.canvas.transform.Find("loadView").gameObject.SetActive(false);
//            };
            UI_Ads.GetInstance.onOpenEvent = delegate() {
                UIManage_TripleJump.GetInstance.ui_Main.SetMainMusicVolume(0);
                CGpCard.GetInstance().SetGiftVisibility(false);
            };
            UI_Ads.GetInstance.onCloseEvent = delegate() {
                UIManage_TripleJump.GetInstance.ui_Main.SetMainMusicVolume(1);
                CGpCard.GetInstance().SetGiftVisibility(true);
            };
        }

        public void GameReset() {
            UIManage.Close<UI_Checkout>();
            ui_Main.GameReset();
            ShowFPS.instance.SetIsShow(false);
        }

        public void GameStart() {
            ui_Main.GameStart();

            UIManage.Open<UI_GameRuning>();
        }

        public void GameEnd() {
            //UI_GameRuning.S_GameEnd();
            UIManage.Close<UI_GameRuning>();
            UI_Tips.GetInstance.GameEnd();
            UIManage.Close<UI_Help>();
        }
    }
}
